﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class cms_Admin_admin_a_Changepas : System.Web.UI.UserControl
{
    static int UserID;
    static string Username = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["uid"] != null) { UserID = int.Parse(Session["uid"].ToString()); }
        if (Session["user"] != null) { Username = Session["user"].ToString(); }
        txtUsername.Text = Username.ToString();
    }
    protected void lbtupdate_Click(object sender, EventArgs e)
    {
        if (txtPass.Text == "")
        {
            lblThongbao.Text = "Password không được trống !!";
            return;
        }
        if (txtXacnhanpass.Text == "")
        {
            lblThongbao.Text = "Nhập lại password và xác nhận lại !!";
            return;
        }
        if (txtPass.Text != txtXacnhanpass.Text)
        {
            lblThongbao.Text = "Xác nhận password sai !!";
            return;
        }
        List<tbUsersDATA> objListUser = tbUserDB.tbUsers_GetByID(UserID.ToString());
        if (objListUser.Count > 0)
        {
            objListUser[0].uID = UserID.ToString();
            objListUser[0].uPass = vmmsclass.Encodingvmms.Encode(txtPass.Text);
            if (tbUserDB.tbUsers_ChangePass(objListUser[0]))
            {
                this.lblThongbao.Text = "Đã sửa password thành công !!!";
                txtPass.Text = "";
                txtXacnhanpass.Text = "";
            }
        }
    }
    protected void lbtback_Click(object sender, EventArgs e)
    {
        Session["c"] = "gtqt";
        Response.Redirect("admin.aspx");
    }
}
